def preprocess_image(imgs_path):
   image = Image.open(self.image_name[idx]) 
   trans = transforms.Resize(size=(image_size,image_size))  
   image = trans(image) 
   image = transforms.ToTensor()(image) 
   image /= 255.0   
   return image
imgs_path="cat.jpg"
img=preprocess_image(imgs_path)
image= img.view(1,3,image_size,image_size)
model.load_state_dict(torch.load(r'./catdog_vgg.pt')) 
#加载模型
model.eval() # 注意：这里测试,model.eval(),training=False 
logits=model(image) 
print(logits))
pred = torch.argmax(logits, axis=1)
print(pred.numpy()) 
